In [6]:
import numpy as np
In [11]:
F=67e6
w = 2 *np.pi * F
Zo = 50
R = 127
L = 200e-9

XInd = complex(0, w*L)
ZL = R * XInd / (R+XInd)
ZL
Out[11]:
(38.77510867003023+58.48871471250831j)
In [13]:
Kl = (ZL-Zo)/(ZL+Zo)
Kl
Out[13]:
(0.21451509450068992+0.5175099556283658j)
In [14]:
d = 6
B = 2 * np.pi * F/(0.66*3e8)
B
Out[14]:
2.126128361520365
In [18]:
KIn_a=np.exp(complex(0,-2*B*d))
KIn_a
Out[18]:
(0.92836793301607212-0.37166245566032857j)
In [19]:
KIn = KIn_a*Kl
KIn
Out[19]:
(0.39148795581985896+0.40071244102361125j)
In [17]:
ZIn = Zo * (1+KIn)/(1-KIn)
ZIn
Out[17]:
(50.000000000178261+4.300598768910977e-10j)
In [21]:
zl = complex(85,32)
z0 = 50
Kl = (zl-z0)/(zl+z0)
Kl
Out[21]:
(0.29866486570730943+0.1662424022027118j)
In [29]:
Kl*Kl.conjugate()*250
Out[29]:
(29.209309574523346+0j)
In [51]:
def V_L(V, Rs, Z0, Zl, n):
    Vf = V*Z0/(Z0+Rs)
    Kl = (Zl - Z0)/(Zl + Z0)
    Ks = (Rs - Z0)/(Rs + Z0)
    
    return (Vf * (1+Kl) * (1 - (Ks*Kl)**n) / (1 - Ks*Kl), Kl, Ks)

v, Kl, Ks = V_L(3.0, 15.0, 88.0, 1000.0, 10000)
v, Kl, Ks
Out[51]:
(2.9556650246305423, 0.8382352941176471, -0.7087378640776699)
In [52]:
Ks * Kl
Out[52]:
-0.5940890919474586
In [55]:
(1+Kl)/(1-Ks*Kl)*2.56
Out[55]:
2.9520824003582624
In [54]:
1+Kl
Out[54]:
1.8382352941176472
In [82]:
def tick(t):
    return V_L(3.0, 10.0, 100.0, 9999999999999.0, t)

ts = np.arange(30)

figure(figsize=(10,10))
plot(ts*25, map(tick, ts))
axhline(2.0)
axhline(2.919)
ylim(2.8,3.0)
Out[82]:
(2.8, 3.0)
In [99]:
def tick(r):
    return (V_L(3.0, 10.0+r, 100.0, 9999999999999.0, 1)[0], V_L(3.0, 10.0+r, 100.0, 9999999999999.0, 2)[0])


rs = np.arange(1000)

figure(figsize=(10,10))

plot(rs, map(tick, rs), '-')

axhline(2.0)
#xlim(0,20)
#ylim(1.9,2.1)
Out[99]:
<matplotlib.lines.Line2D at 0x105d985d0>
In [100]:
def tick(r):
    return V_L(3.0, 10.0, 100.0, r, 2)[0]


rs = np.arange(1000)

figure(figsize=(10,10))

plot(rs, map(tick, rs), 'o')

axhline(2.0)
#xlim(545,555)
#ylim(1.9,2.1)
Out[100]:
<matplotlib.lines.Line2D at 0x105aab310>
In [57]:
%pylab inline
Populating the interactive namespace from numpy and matplotlib

In [80]:
def settle_over(V, Rs, Z0, Zl, V_target):
    _, Kl, Ks = V_L(V, Rs, Z0, Zl, 1)
    
    Vf = V * Z0/(Rs+Z0)
    
    t = (V_target-Vf)/Vf
    
    n = (np.log( (t) * (1-Ks*Kl)/(1+Kl)) / np.log(-1*Ks*Kl))
    
    return (n, t, Vf, Ks, Kl)
    
    return (np.log(  (V_target)*(1-Ks*Kl)/(Vf)/(1+Kl) - 1 ) / np.log(Ks*Kl), Vf, Ks, Kl)

settle_over(3.0, 10.0, 100.0, 99999999999, 2.9)
Out[80]:
(14.225563130523863,
 0.06333333333333338,
 2.727272727272727,
 -0.8181818181818182,
 0.9999999980000001)
In [75]:
16*25
Out[75]:
400
In [102]:
2*np.pi*(0.241*1e-6)*41e6, 1/(2*np.pi*41e6*44e-12)
Out[102]:
(62.084154020241485, 88.22336091568478)
In [110]:
Zl = complex(0,62) + (complex(0,-88)*154)/(154+complex(0,-88))
Zl
Out[110]:
(37.90769230769231-4.338461538461544j)
In [111]:
(Zl-50)/(Zl+50)
Out[111]:
(-0.1347929012885083-0.05600482992008396j)
In [113]:
1.0/Inf
Out[113]:
0.0
In [117]:
try:
    x = 1.0/20
except ZeroDivisionError:
    x = Inf
    
x
Out[117]:
0.05
In [124]:
20*(log10(sinc(1.0/50)) - log10(sinc(1.0/5)))
Out[124]:
0.57350782269122136
In [122]:
xs = np.arange(100)*np.pi
plot(xs, sinc(xs))
Out[122]:
[<matplotlib.lines.Line2D at 0x105ad9b10>]
In [137]:
def alpf(Fs, N, f):
    return np.abs(1.0/N*sin(N*np.pi*f/Fs)/sin(np.pi*f/Fs))

def dB(x):
    return 10*np.log(x)

def H_alpf(Fs, N, f):
    return dB(alpf(Fs, N, f))

Fs=200
Fs_disp=10000
freqs=np.arange(Fs)+1

figure(figsize=(10,10))
plot(freqs*Fs_disp/Fs, H_alpf(Fs, 8, freqs))
xlim(0,Fs_disp/2)
ylim(-40,0)
Out[137]:
(-40, 0)
In [140]:
Fs=200
Fs_disp=100000
freqs=np.arange(Fs)+1

figure(figsize=(10,10))
plot(freqs*Fs_disp/Fs, dB(alpf(Fs, 7, freqs)*alpf(Fs,5,freqs)))
plot(freqs*Fs_disp/Fs, H_alpf(Fs, 7, freqs))
plot(freqs*Fs_disp/Fs, H_alpf(Fs, 5, freqs))

xlim(0,Fs_disp/2)
ylim(-40,0)
Out[140]:
(-40, 0)
In []: